<?php

namespace App\Kuafu\Pay\Command;

use App\Kuafu\Pay\Model\PayStreamModel;
use App\Kuafu\Pay\Service\PayService;
use Illuminate\Console\Command;

class RefundTest extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'pay:refund {payNo}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '初始化payStream表bizId';

    /**
     * Create a new command instance.
     *
     * @return void//
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command
     *
     * @return int
     */
    public function handle()
    {
        $payNo = $this->argument('payNo');
        if (!$payNo) {
            dd('payNo不能为空');
        }

        $stream = PayStreamModel::getDataByPayNo($payNo);
        if (!$stream) {
            dd('不存在的payNo');
        }

        $a = PayService::sRefund(
            $shopId = $stream->shopId,
            $orderId = $stream->orderId,
            $refundPrice = $stream->payPrice,
            $callbackUrl = '',
            $payNo,
            $subject = '测试退款'
        );
        dd($a);
    }
}
